﻿using System;
using System.Diagnostics.CodeAnalysis;
using Beaker.OpenCube.Render.Maths;
using FluentAssertions;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Beaker.OpenCube.Render.Specs
{
	[ExcludeFromCodeCoverage]
	[TestClass]
	public class ColorSpecs
	{
		[TestMethod]
		public void OperatorAdd_ColorColor_Color()
		{
			// arrange
			Color c1 = new Color( 0, 1, 0.25 );
			Color c2 = new Color( 1, 0, 0.25 );

			// act
			Color c = c1 + c2;

			// assert
			c.R.Should().Be( 1 );
			c.G.Should().Be( 1 );
			c.B.Should().Be( 0.5 );
		}

		[TestMethod]
		public void OperatorMultiply_ColorDouble_Color()
		{
			// arrange
			Color c1 = new Color( 1, 0.5, 0 );
			double m = 0.25;

			// act
			Color c = c1 * m;

			// assert
			c.R.Should().Be( 0.25 );
			c.G.Should().Be( 0.125 );
			c.B.Should().Be( 0 );
		}

		[TestMethod]
		public void OperatorMultiply_ColorColor_Color()
		{
			// arrange
			Color c1 = new Color( 0, 1, 0.25 );
			Color c2 = new Color( 1, .5, 0.25 );

			// act
			Color c = c1 * c2;

			// assert
			c.R.Should().Be( 0 );
			c.G.Should().Be( .5 );
			c.B.Should().Be( 0.25 * 0.25 );
		}

		[TestMethod]
		public void OperatorMultiply_DoubleColor_Color()
		{
			// arrange
			Color c1 = new Color( 1, 0.5, 0 );
			double m = 0.25;

			// act
			Color c = m * c1;

			// assert
			c.R.Should().Be( 0.25 );
			c.G.Should().Be( 0.125 );
			c.B.Should().Be( 0 );
		}

		[TestMethod]
		public void OperatorDivide_ColorDouble_Color()
		{
			// arrange
			Color c1 = new Color( 1, 0.5, 0 );
			double m = 0.25;

			// act
			Color c = c1 / m;

			// assert
			c.R.Should().Be( 4 );
			c.G.Should().Be( 2 );
			c.B.Should().Be( 0 );
		}

		[TestMethod]
		public void InstancePower2_ColorDouble_Color()
		{
			// arrange
			Color c1 = new Color( 0.8, 0.5, 0.1 );

			// act
			Color c = c1.Power2();

			// assert
			c.R.Should().Be( 0.8 * 0.8 );
			c.G.Should().Be( 0.5 * 0.5 );
			c.B.Should().Be( 0.1 * 0.1 );
		}

		[TestMethod]
		public void InstancePower_ColorDouble_Color()
		{
			// arrange
			Color c1 = new Color( 0.8, 0.5, 0.1 );
			double p = 3;

			// act
			Color c = c1.Power( p );

			// assert
			c.R.Should().Be( 0.8 * 0.8 * 0.8 );
			c.G.Should().Be( 0.5 * 0.5 * 0.5 );
			c.B.Should().Be( 0.1 * 0.1 * 0.1 );
		}
	}
}
